"""Common types for encoder and decoder"""

DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"

# Data Formats
BINN_LIST = 0xe0
BINN_MAP = 0xe1
BINN_OBJECT = 0xe2

BINN_STRING = 0xa0
BINN_TIME = 0xa1  # Not used
BINN_DATETIME = 0xa2

BINN_BLOB = 0xc0

BINN_NULL = 0x00
BINN_TRUE = 0x01
BINN_FALSE = 0x02

BINN_UINT8 = 0x20
BINN_INT8 = 0x21
BINN_UINT16 = 0x40
BINN_INT16 = 0x41
BINN_UINT32 = 0x60
BINN_INT32 = 0x61
BINN_UINT64 = 0x80
BINN_INT64 = 0x81
BINN_FLOAT32 = 0x62
BINN_FLOAT64 = 0x82
BINN_BOOL = 0x80061

def is_unsigned_int(typ):
    return typ == BINN_UINT8 or typ == BINN_UINT16 or typ == BINN_UINT32 or typ == BINN_UINT64
def is_signed_int(typ):
    return typ == BINN_INT8 or typ == BINN_INT16 or typ == BINN_INT32 or typ == BINN_INT64 or typ == BINN_BOOL

def is_int(typ):
    return is_unsigned_int(typ) or is_signed_int(typ)

def is_floating_point(typ):
    return typ == BINN_FLOAT32 or typ == BINN_FLOAT64
# Extended data formats
PYBINN_MAP = 0xb8
PYBINN_MAP_SIZE = 8

ALL = (
    BINN_LIST,
    BINN_MAP,
    BINN_OBJECT,
    BINN_STRING,
    BINN_DATETIME,
    BINN_BLOB,
    BINN_NULL,
    BINN_TRUE,
    BINN_FALSE,
    BINN_UINT8,
    BINN_INT8,
    BINN_UINT16,
    BINN_INT16,
    BINN_UINT32,
    BINN_INT32,
    BINN_UINT64,
    BINN_INT64,
    BINN_FLOAT32,
    BINN_FLOAT64,
    PYBINN_MAP
)
